package com.bum.rss.bo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bum.rss.exp.om.RssEntry;
import com.bum.rss.site.Site;

public class SiteFactory {
	private Map<String, Site>	siteMap;
	public List<RssEntry>		siteEntrys;

	public List<RssEntry> getSiteEntrys() {
		return siteEntrys;
	}

	public Site get(String code) {
		return siteMap.get(code);
	}

	private void setup(List<Site> sites) {
		int siteCount = sites.size();

		siteMap = new HashMap<String, Site>(siteCount);
		siteEntrys = new ArrayList<RssEntry>(siteCount);
		for (Site site : sites) {
			siteMap.put(site.getCode(), site);

			if (!site.isHide()) {
				siteEntrys.add(new RssEntry(site.getCode(), site.getTitle()));
			}
		}
	}

	/**
	 * SETTERS
	 */
	public void setSites(List<Site> sites) {
		setup(sites);
	}
}
